//
//  GluDiabetAssesItem.m
//  CareRingApp
//
//  Created  on 2025/2/28.
//
    

#import "GluDiabetAssesItem.h"
#import <Masonry/Masonry.h>
#import <QMUIKit/QMUIKit.h>
@implementation GluDiabetAssesItem
{
    UIImageView *_iconView1, *_iconView2, *_iconView3, *_iconView4;
    QMUIButton *_titlBtn;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self layoutBase];
        
    }
    return self;
}
-(void)layoutBase
{
    _iconView1 = [UIImageView new];
    _iconView1.contentMode = UIViewContentModeScaleAspectFit;
    
    _iconView2 = [UIImageView new];
    _iconView2.contentMode = UIViewContentModeScaleAspectFit;
    
    _iconView3 = [UIImageView new];
    _iconView3.contentMode = UIViewContentModeScaleAspectFit;
    
    _iconView4 = [UIImageView new];
    _iconView4.contentMode = UIViewContentModeScaleAspectFit;
    
    UIFont *plusFont = [UIFont fontWithName:@"Arial-BoldMT" size:18];
    
    UILabel *lbl1 = [UILabel new];
    lbl1.textAlignment = NSTextAlignmentCenter;
    lbl1.text = @"+";
    
    UILabel *lbl2 = [UILabel new];
    lbl2.textAlignment = NSTextAlignmentCenter;
    lbl2.text = @"+";

    UILabel *lbl3 = [UILabel new]; // 等号
    lbl3.textAlignment = NSTextAlignmentCenter;
    lbl3.text = @"=";
    
    lbl1.font = plusFont;
    lbl2.font = plusFont;
    lbl3.font = plusFont;

    _titlBtn = [[QMUIButton alloc]init];
    [_titlBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    _titlBtn.userInteractionEnabled = NO;
    _titlBtn.contentEdgeInsets = UIEdgeInsetsMake(3, 8, 3, 8);
    [_titlBtn.titleLabel setNumberOfLines:0];
    
    [_titlBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
    
    [self addSubview:_iconView1];
    [self addSubview:_iconView2];
    [self addSubview:_iconView3];
    [self addSubview:_iconView4];

    [self addSubview:_titlBtn];
    
    [self addSubview:lbl1];
    [self addSubview:lbl2];
    [self addSubview:lbl3];

    [_titlBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(_titlBtn.superview.mas_trailing);
        make.height.equalTo(@45);
        make.width.equalTo(@130);
        make.centerY.equalTo(_iconView1);
    }];
    
    
    [_iconView1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(_iconView1.mas_height);
        make.height.lessThanOrEqualTo(@35);
        make.leading.equalTo(_iconView1.superview);
        make.top.equalTo(_iconView1.superview).offset(5);
        make.bottom.equalTo(_iconView1.superview).inset(5);
    }];
    
    [lbl1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(_iconView1);
        make.leading.equalTo(_iconView1.mas_trailing);
        make.width.lessThanOrEqualTo(@15);
    }];
    
    [_iconView2 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(_iconView2.mas_height);
        make.height.equalTo(_iconView1);
        
        make.leading.equalTo(lbl1.mas_trailing);
        make.centerY.equalTo(_iconView1);
    }];
    
    [lbl2 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(_iconView1);
        make.leading.equalTo(_iconView2.mas_trailing);
        make.width.lessThanOrEqualTo(@15);
    }];
    
    [_iconView3 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(_iconView3.mas_height);
        make.height.equalTo(_iconView1);
        
        make.leading.equalTo(lbl2.mas_trailing);
        make.centerY.equalTo(_iconView1);
    }];
    
    [lbl3 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(_iconView1);
        make.leading.equalTo(_iconView3.mas_trailing);
        make.width.lessThanOrEqualTo(@15);
    }];
    
    [_iconView4 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(_iconView3.mas_height);
        make.height.equalTo(_iconView1);
        
        make.leading.equalTo(lbl3.mas_trailing);
        make.centerY.equalTo(_iconView1);
        make.trailing.equalTo(_titlBtn.mas_leading).inset(8);
    }];
    
    
    _titlBtn.cornerRadius = 40 /2.0f;

    
    
}
-(void)setImg1:(UIImage *)img1 Img2:(UIImage *)img2 Img3:(UIImage *)img3 Img4:(UIImage *)img4 BtnColor:(UIColor *)btnColor BtnTxt:(NSString *)btnTxt
{
    _iconView1.image = img1;
    _iconView2.image = img2;
    _iconView3.image = img3;
    _iconView4.image = img4;
    
    _titlBtn.backgroundColor = btnColor;
    [_titlBtn setTitle:btnTxt forState:UIControlStateNormal];

}



@end
